<template>
  <el-form ref="form" :model="formData" label-width="120px">
    <el-row>
      <el-col :span="12">
        <el-form-item label="申请ID"> <span>{{ formData.applyId }}</span> </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="申请状态"> <span>{{ selectDictLabel(statusOptions,formData.status) }}</span> </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="申请者"> <span>{{ formData.userName }}</span> </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="请假天数"> <span>{{ formData.leaveDays }}</span> </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="申请时间"> <span>{{ formData.createTime }}</span> </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="更新时间"> <span>{{ formData.updateTime }}</span> </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-form-item label="备注"> <span>{{ formData.remark }}</span> </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
import { selectById } from "@samples/api/samples/leave";

export default {
  name: "SamplesWfLeaveViewForm",
  props: {
    applyId: {
      required: true,
      type: String,
      default: undefined
    },
  },
  data() {
    return {
      // 审批状态的数据字典选项列表：samples_leave_status
      statusOptions: [],
      formData: {},
    }
  },
  watch: {
    applyId(newVal, oldVal) {
      this.init();
    }
  },
  created() {
    this.init();

    // 获取数据字典：samples_leave_status
    this.getDicts("samples_leave_status").then(response => {
      this.statusOptions = response.data;
    });
  },
  methods: {
    init() {
      if (this.applyId !== undefined) {
        selectById(this.applyId).then(response => {
          if(response.data === null || response.data === undefined){
            this.msgError("请假单信息未获取到或已删除");
          }
          this.formData = response.data || {};
        });
      }
      console.log("this.formData=",this.formData);
    },
  }
}
</script>

<style lang="scss" scoped>
</style>